package com.hsxazj.springkafka.controller;

import com.hsxazj.springkafka.utils.JsonUtils;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class KafkaConsumer {

    // 监听消费
    @KafkaListener(topics = {"sb_topic"})
    public void onNormalMessage(ConsumerRecord<String, Object> record) {
        String s = record.value().toString();
        Map<String, Object> map = JsonUtils.simpleTransfer(s);
        map.forEach((K, V) -> System.out.println(K + "----->" + V));
    }

}
